package com.bobo.service.impl;

import com.bobo.base.mybatis.ServiceImpl;
import com.bobo.mapper.IndexImgMapper;
import com.bobo.mapper.ProdCommMapper;
import com.bobo.pojo.IndexImg;
import com.bobo.pojo.ProdComm;
import com.bobo.service.IndexImgService;
import com.bobo.service.ProdCommService;
import com.bobo.util.Arith;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

@Service
public class ProdCommServiceImpl extends ServiceImpl<ProdCommMapper, ProdComm> implements ProdCommService {
    @Resource
    private ProdCommMapper prodCommMapper;
    @Override
    public ProdComm getProdCommDataByProdId(Long prodId) {
        ProdComm prodComm= prodCommMapper.getProdCommDataByProdId(prodId);
        //计算出好评率
        if(prodComm.getPraiseNumber() == 0||prodComm.getNumber() == 0){
            prodComm.setPositiveRating(0.0);
        }else{
            prodComm.setPositiveRating(Arith.mul(Arith.div(prodComm.getPraiseNumber(),prodComm.getNumber()),100));
        }
        return prodComm;
    }
}
